﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CTP.Exceptions
{
    internal class ErrorCode
    {
        public const int Success = 1;
        public const int UnHandle = -100;
        public const int ConnectTimeout = -101;
        public const int ConnectFailt = -102;
        public const int UnConnected = -103;

        public const int ReLogin = -1001;
        public const int LoginCmdSendFailt = -1002;
        public const int QrySettlementCmdSendFailt = -1003;
        public const int ConfirmSettlementCmdSendFailt = -1004;
        public const int QueryAccountSummaryCmdSendFailt = -1005;
        public const int PlaceOrderCmdSendFailt = -1007;
        public const int QueryOrderStatusCmdSendFailt = -1008;
        public const int CancelOrderCmdSendFailt = -1009;
        public const int QueryTodayOrderRequestCmdSendFailt = -1010;
        public const int QueryTodayFilledCmdSendFailt = -1011;
        public const int QueryPositionCmdSendFailt = -1012;
        public const int LogoutCmdSendFailt = -1013;

        public const int NotLogin = -2000;
        public const int LoginFailt = -2001;
        public const int PlaceOrderRejectByCTP = -2002;
        public const int PlaceOrderRejectByMarket = -2003;
        public const int CancelOrderRejectByCTP = -2004;
        public const int CancelOrderRejectByMarket = -2005;
        public const int QueryAccountInfoFailt = -2006;
        public const int QuerySettlementInfoFailt = -2007;
        public const int ConfirmSettlementInfoFailt = -2008;
        public const int QueryTodayOrderFailt = -2009;

        public static string GetErrorMessage(int errCode)
        {
            switch (errCode)
            {
                case 0: return "";
                case UnHandle: return "未处理的错误";
                case ConnectTimeout: return "连接超时";
                case ConnectFailt: return "连接失败";
                case UnConnected: return "未连接";

                case ReLogin: return "资金账号重复登陆";
                case LoginCmdSendFailt: return "资金账号登陆命令发送失败";
                case QrySettlementCmdSendFailt: return "查询资金账号确认命令发送失败";
                case ConfirmSettlementCmdSendFailt: return "资金账号确认命令发送失败";
                case QueryAccountSummaryCmdSendFailt: return "资金账号明细命令发送失败";
                case PlaceOrderCmdSendFailt: return "下单命令发送失败";
                case QueryOrderStatusCmdSendFailt: return "查询委托单状态命令发送失败";
                case CancelOrderCmdSendFailt: return "撤单命令发送失败";
                case QueryTodayOrderRequestCmdSendFailt: return "查询今日委托命令发送失败";
                case QueryTodayFilledCmdSendFailt: return "查询今日成交命令发送失败";
                case QueryPositionCmdSendFailt: return "查询持仓命令发送失败";
                case LogoutCmdSendFailt: return "资金账号登出命令发送失败";

                case NotLogin: return "未登陆";
                case LoginFailt: return "登陆失败";
                case PlaceOrderRejectByCTP: return "下单被拒绝[CTP拒绝]";
                case PlaceOrderRejectByMarket: return "下单被拒绝[来自市场]";
                case CancelOrderRejectByCTP: return "撤单被拒绝[CTP拒绝]";
                case CancelOrderRejectByMarket: return "撤单被拒绝[来自市场]";
                case QueryAccountInfoFailt: return "查询资金账号失败";
                case QuerySettlementInfoFailt: return "查询结算信息失败";
                case ConfirmSettlementInfoFailt: return "确认结算信息失败";
                case QueryTodayOrderFailt: return "查询报单失败";


            }

            return "未知的错误";
        }
    }
}
